package com.ssm.student.service.impl;


import com.ssm.student.dao.PersonalMapper;
import com.ssm.student.dao.RoleMapper;
import com.ssm.student.model.Personal;

import com.ssm.student.model.Role;
import com.ssm.student.service.PersonalService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PersonalServicelmpl implements PersonalService {



    private PersonalMapper personalMapper;
    /*
     * 人员信息添加方式实现
     * @param role 人员实体
     * @return 是否成功（—1：含有重复信息）
     * */


    public int insertPersonal(Personal personal) {
        int returnInt=0;
        /*1业务的判断
        （1）身份证不能重复
        */
        //（1）身份证不能重复
        int personalNumberCount=personalMapper.getPersonalnumber(personal.personalnumber);
        if (personalNumberCount<2){


            //2数据的添加
            int addPowerInt=personalMapper.insertPersonal((PersonalMapper) personal);


            //3返回值的设置
            returnInt=addPowerInt;
        }else{
            returnInt=-1;//有相同的身份证号
        }
        return 0;
    }
}
